Type Checking C++ Template Instantiation by Graph Programs
نویسندگان
چکیده
Templates are a language feature of C++ and can be used for metapro-gramming. The metaprogram is executed by the compiler and outputs source code which is then compiled. Templates are widely used in software libraries but few tools exist for programmers developing template code. In particular, error messages are often cryptic. During template instantiation, a compiler looks up names that depend on a template's formal parameters. We use graphs to represent the relevant parts of the source code and a graph program for the name lookup and type checking for expressions involving such names. This technique provides compiler writers with a visual way of writing algorithms that generate error messages and forms the basis for a visual inspection of type problems and suggested remedies for the programmer. Our graph program terminates and emits correct error messages.
منابع مشابه
Automatic Template Instantiation in DIGITAL C++
Vol. 10 No. 1 1998 The template facility within the C++ language allows the user to provide a template for a class or function and then apply specific arguments to the template to specify a type or function. The process of applying arguments to a template, referred to as template instantiation, causes specific code to be generated to implement the functions and static data members of the instan...
متن کاملPatterns in datatype - generic programming ( extended abstract )
Generic programming [14, 10] is a matter of making programs more adaptable by making them more general. In particular, it consists of allowing a wider variety of entities as parameters than is available in more traditional programming languages. The most popular instantiation of generic programming today is through the C++ Standard Template Library (stl) of container classes and generic algorit...
متن کاملChecking termination of bottom-up evaluation of logic programs with function symbols
Recently, there has been an increasing interest in the bottom-up evaluation of the semantics of logic programs with complex terms. The presence of function symbols in the program may render the ground instantiation infinite, and finiteness of models and termination of the evaluation procedure, in the general case, are not guaranteed anymore. Since the program termination problem is undecidable ...
متن کاملAnalysis Type Lex / Parse Translation Optimizer Back End AST AST
This paper proposes an alternate structure for C++ compilers. Type analysis is removed from the compiler and replaced with a type system library which is treated as source code by the compiler. Type computations are embedded in the intermediate language of the compiler, and partial evaluation is used to drive type analysis and template in-stantiation. By making simple changes to the behavior of...
متن کاملChecking Termination of Queries to Logic Programs
Termination of programs is known to be undecidable. However in the case of logic programs , where the only possible cause for non-termination is innnite recursion, termination can actually be proved automatically for a large class of programs. This paper describes an algorithm for automatically checking termination of queries to logic programs. Given a program and query the algorithm either ans...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- ECEASST
دوره 10 شماره
صفحات -
تاریخ انتشار 2008